import {getTaskInfo,knowledEexamineChecksstatus,knowledgeExamineCheckStatus,knowledgeExamineCheckProcess,examinationData,retest,similarAskList,deleteSimilarQuestions,movingSimilarQuestions,ignoreSimilarQue,allIgnoreSimilarQue,getAbnormalList,ignoreAbnormalQuestion,allIgnoreAbnormalQuestion,deleteAbnormalQuestion,relationWaitLearnQa,addToOtherQa,fakeAnswerRelevanceData } from '@/services/capacityStudy';

export default {
  namespace:'medicalKnowledge',

  state: {
  
  },
  effects: { // 未知问题 列表
    *getTaskInfo({ payload, callback }, { call, put }) {
      const response = yield call(getTaskInfo, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetch({ payload, callback }, { call, put }) {
      const response = yield call(examinationData, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *retest({ payload, callback }, { call, put }) { // 知识库体检 重新检测
      const response = yield call(retest, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *similarAskList({ payload, callback }, { call, put }) { // 知识库体验 相似问列表
      const response = yield call(similarAskList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *deleteSimilarQuestions({ payload, callback }, { call, put }) { // 知识库体验 删除相似问
      const response = yield call(deleteSimilarQuestions, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *movingSimilarQuestions({ payload, callback }, { call, put }) { // 知识库体验 移动相似问
      const response = yield call(movingSimilarQuestions, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *ignoreSimilarQue({ payload, callback }, { call, put }) { // 知识库体验 忽略/恢复相似问
      const response = yield call(ignoreSimilarQue, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *allIgnoreSimilarQue({ payload, callback }, { call, put }) { // 知识库体验 忽略/恢复相似问
      const response = yield call(allIgnoreSimilarQue, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *getAbnormalList({ payload, callback }, { call, put }) { // 知识库体验 异常问列表
      const response = yield call(getAbnormalList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *ignoreAbnormalQuestion({ payload, callback }, { call, put }) { // 知识库体验 忽略/恢复异常问
      const response = yield call(ignoreAbnormalQuestion, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *allIgnoreAbnormalQuestion({ payload, callback }, { call, put }) { // 知识库体验 忽略/恢复异常问
      const response = yield call(allIgnoreAbnormalQuestion, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *deleteAbnormalQuestion({ payload, callback }, { call, put }) { // 知识库体验 删除异常问
      const response = yield call(deleteAbnormalQuestion, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *relationWaitLearnQa({ payload, callback }, { call, put }) { // 知识库体验 关联知识点
      const response = yield call(relationWaitLearnQa, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *addToOtherQa({ payload, callback }, { call, put }) { // 知识库体验 关联异常问
      const response = yield call(addToOtherQa, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fakeAnswerRelevanceData({ payload, callback }, { call, put }) { // 知识库体验 关联
      const response = yield call(fakeAnswerRelevanceData, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *knowledgeExamineCheckProcess({ payload, callback }, { call, put }) { // 知识库体验 获取体检进度
      const response = yield call(knowledgeExamineCheckProcess, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *knowledgeExamineCheckStatus({ payload, callback }, { call, put }) { // 知识库体验 任务状态
      const response = yield call(knowledgeExamineCheckStatus, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *knowledEexamineChecksstatus({ payload, callback }, { call, put }) { // 知识库体验 任务状态
      const response = yield call(knowledEexamineChecksstatus, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    }
  },
  
  
  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
    clear() {
      return {
       
      };
    },
  },
};
